﻿using AutoTest.Framework.Pager;

namespace AutoTest.Framework.Extensions
{
    public static class PageExtension
    {
        /// <summary>
        /// 分页对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="searchDto"></param>
        /// <param name="dataList"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public static PagedList<T> ToPagedList<T>(this IPagedSearchDto? searchDto, List<T> dataList = null!, int count = 0)
        {
            return new PagedList<T>(searchDto?.PageIndex ?? 1, searchDto?.PageSize ?? 20)
            {
                ItemList = dataList,
                RecordCount = count
            };
        }
    }
}
